#!/usr/bin/env python3
# -*-coding:utf-8 -*-
# __author__=LuLu
from selenium.webdriver.common.by import By

'''
话题的元素类
'''


class TopicAndThemeLoc(object):
    # 搜索id输入框
    search_id = (By.XPATH, '//*[@id="wxh"]')
    # 关键词搜索
    search_keyword = (By.XPATH, '//*[@id="yq"]')
    # 搜索按钮
    search_button = (By.XPATH, '//*[@id="search-btn"]')
    # 清空按钮
    clean_button = (By.XPATH, '//*[@id="search-clean-btn"]')
    # 新增话题/主题
    addTopicAndTheme_button = (By.XPATH, '//*[@id="etravel"]/div/div[3]/div/div[1]/div[3]/button[1]')
    # 勾选删除
    select_delete_button = (By.XPATH, '//*[@id="etravel"]/div/div[3]/div/div[1]/div[3]/button[2]')  # 删除按钮
    # 确定删除
    delete_yes = (By.XPATH, '//*[starts-with(@id,"Modalx")]/div/div/div/div[3]/button[2]')
    # 取消删除
    delete_no = (By.XPATH, '//*[starts-with(@id,"Modalx")]/div/div/div/div[3]/button[1]')
    # 提示
    toast_warn = (By.XPATH, '//*[@id="msgcontainer-toast"]')

    # 表格
    list_table = (By.XPATH, '//*[@id="etravel"]/div/div[3]/div/div[3]/div/div[1]/div[2]/div[2]/table/tbody')

    # 全选 --公共函数--selectBoxLocators-->select_all
    # 单选 --公共函数--selectBoxLocators-->select_one_box
    # 指定整行
    def one_rows(self):
        return By.XPATH, f'//*[@id="etravel"]/div/div[3]/div/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr[{self}]'

    # 编辑话题/主题
    def edit_one(self):
        return By.XPATH, f'//*[@id="etravel"]/div/div[3]/div/div[3]/div/div[1]/div[2]/div[2]/table/tbody' \
                         f'/tr[{self}]/td[10]/a[1]'

    def delete_one(self):
        return By.XPATH, f'//*[@id="etravel"]/div/div[3]/div/div[3]/div/div[1]/div[2]/div[2]/table/tbody' \
                         f'/tr[{self}]/td[10]/a[2]'

    '''翻页控件'''
    PageNum = (By.XPATH, '//*[@id="etravel"]/div/div[3]/div/div[3]/div/div[1]/div[3]/div[1]/span[1]')
    PageTurn = (By.XPATH, '//*[@id="etravel"]/div/div[3]/div/div[3]/div/div[1]/div[3]/div[2]/ul')

    '''
    新增/编辑弹框
    '''
    # 窗口标题
    win_title = (By.XPATH, '//*[@id="modal-item"]/div/div[1]')
    # 编辑窗口产品id
    edit_id = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/div[1]/div[1]/p[2]')
    # 主标题
    topic_main_title = (By.XPATH, '//*[@id="talkTitle"]')
    subject_main_title = (By.XPATH, '//*[@id="subjectName"]')
    edit_main_title = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/div[1]/div[2]/p[2]')
    # 主标题长度
    main_length = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[1]/div[2]/span[2]/p')
    # 副标题
    topic_sub_title = (By.XPATH, '//*[@id="talkSubTitle"]')
    subject_sub_title = (By.XPATH, '//*[@id="subjectSubName"]')
    # 副标题长度
    sub_length = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[2]/div[2]/span[2]/p')
    # 排序问号
    question_mark = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[3]/div[1]/span[2]/div/div/i')
    # 问号提示内容
    question_tips = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[3]/div[1]/span[2]/div/div/div')
    # 排序
    sorted = (By.XPATH, '//*[@id="sortIndex"]')
    # 选择图片
    select_Logo_button = (By.XPATH, '//*[@id="talkLogo"]/div/div/ul/li[2]/div')
    # 删除图片
    delete_Logo_button = (By.XPATH, '//*[@id="talkLogo"]/div/div/ul/li/div[1]/div/a')
    # 确定按钮
    commit_button = (By.XPATH, '//*[@id="modal-item"]/div/div[3]/a[2]')
    # 取消按钮
    cancel_button = (By.XPATH, '//*[@id="modal-item"]/div/div[3]/a[1]')
    # 关闭弹框
    close_button = (By.XPATH, '//*[@id="modal-item"]/div/div[1]/i')

    # 图片上传成功
    def logo_upload_success(self):
        # subjectLogo -主题logo
        # talkLogo -话题logo
        dit = {'主题': 'subjectLogo', '话题': 'talkLogo'}
        return By.XPATH, f'//*[@id="{dit[self]}"]/div/div/ul/li/div[1]/div/div/img'  # 目的地Logo成功回显

    """
    新增编辑异常提示框
    """
    main_name_warn = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[1]/div[2]/span[1]')
    sub_name_warn = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[2]/div[2]/span[1]')
    sorted_warn = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[3]/div[2]/span')
    LOGO_warn = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[4]/div[2]/span[2]')
    upload_warn = (By.XPATH, '//*[@id="msgcontainer"]')
    toast_warn = (By.XPATH, '//*[@id="msgcontainer-toast"]')
